<%@ page import="com.dingpeikeji.quickdeer.core.modules.sys.entity.Office"
	contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<c:set var="FLAT_TYPE_BUS" value="<%=Office.FLAT_TYPE_BUS%>"></c:set>
<c:set var="FLAT_TYPE_ENTERPRISE"
	value="<%=Office.FLAT_TYPE_ENTERPRISE%>"></c:set>
<html>
<head>
<title><c:choose>
		<c:when test="${office.flatType == FLAT_TYPE_BUS }">车队管理</c:when>
		<c:when test="${office.flatType == FLAT_TYPE_ENTERPRISE }">旅行商管理</c:when>
		<c:otherwise>未知</c:otherwise>
	</c:choose></title>
<meta name="decorator" content="default" />
<script type="text/javascript">
	$(document).ready(
			function() {
				$("#name").focus();
				$("#inputForm")
						.validate(
								{
									rules: {
										orgcode: {remote: "${ctx}/sys/office/checkOrgcode?oldOrgcode=" + encodeURIComponent('${office.orgcode}') + "&flatType=" +'${office.flatType}'},
										name: {remote: "${ctx}/sys/office/checkOfficeName?oldOfficeName=" + encodeURIComponent('${office.name}') + "&flatType=" +'${office.flatType}'},
										licenseno: {remote: "${ctx}/sys/office/checkLicenseno?oldLicenseno=" + encodeURIComponent('${office.licenseno}') + "&flatType=" +'${office.flatType}'},
										taxregno: {remote: "${ctx}/sys/office/checkTaxregno?oldTaxregno=" + encodeURIComponent('${office.taxregno}') + "&flatType=" +'${office.flatType}'}
									},
									messages: {
										orgcode: {remote: "组织机构代码已存在"},
										name: {remote: "公司名已存在"},
										licenseno: {remote: "营运执照编码已存在"},
										taxregno: {remote: "税务登记证已存在"}
									},
									submitHandler : function(form) {
										loading('正在提交，请稍等...');
										form.submit();
									},
									errorContainer : "#messageBox",
									errorPlacement : function(error, element) {
										$("#messageBox").text("输入有误，请先更正。");
										if (element.is(":checkbox")
												|| element.is(":radio")
												|| element.parent().is(
														".input-append")) {
											error.appendTo(element.parent()
													.parent());
										} else {
											error.insertAfter(element);
										}
									}
								});
			});
	//根据是否退票展示修改退票规则
	function isreturnChange(value) {
		if (value == 1) {
			document.getElementById("cont").style.display = "block";
		} else {
			document.getElementById("cont").style.display = "none";
			$(returnid).val(0);
		}
	}
	//验证合作伙伴权重为数字
	function validateNum() {
		var reg = new RegExp("^[0-9]*$");
		var obj = document.getElementById("prtyorder").value;
		if (!/^[0-9]*$/.test(obj)) {
			alert("请输入大于等于1的数字!");
		}
		if (obj < 1) {
			alert("权重必须大于等于1!");
		}

	}
	//验证组织机构码是否有效
	function validateOrgcode() {
		var orgcode = document.getElementById("orgcode").value;
		var ws = [ 3, 7, 9, 10, 5, 8, 4, 2 ];
		var str = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
		var reg = /^([0-9A-Z]){8}-[0-9|X]$/;
		if (!reg.test(orgcode)) {
			alert("组织机构代码格式不正确！");
			return false;
		}
	}
</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><c:choose>
				<c:when test="${office.flatType == FLAT_TYPE_BUS }">
					<a href="${ctx}/sys/office/busList">车队列表</a>
				</c:when>
				<c:when test="${office.flatType == FLAT_TYPE_ENTERPRISE }">
					<a href="${ctx}/sys/office/enterpriseList">旅行商列表</a>
				</c:when>
				<c:otherwise>未知</c:otherwise>
			</c:choose></li>
		<li class="active"><shiro:hasPermission name="sys:office:edit">
				<c:set var="formNamePart" value="${not empty office.id?'修改':'添加'}"></c:set>
			</shiro:hasPermission> <shiro:lacksPermission name="sys:office:edit">
				<c:set var="formNamePart" value="查看"></c:set>
			</shiro:lacksPermission> <c:choose>
				<c:when test="${office.flatType == FLAT_TYPE_BUS }">
					<a
						href="${ctx}/sys/office/form?id=${office.id}&flatType=${FLAT_TYPE_BUS}">车队${formNamePart }</a>
				</c:when>
				<c:when test="${office.flatType == FLAT_TYPE_ENTERPRISE }">
					<a
						href="${ctx}/sys/office/form?id=${office.id}&flatType=${FLAT_TYPE_ENTERPRISE}">旅行商${formNamePart }</a>
				</c:when>
				<c:otherwise>未知</c:otherwise>
			</c:choose></li>
	</ul>
	<br />
	<form:form id="inputForm" modelAttribute="office"
		action="${ctx}/sys/office/save" method="post" class="form-horizontal">
		<form:hidden path="id" />
		<!-- 平台类型 -->
		<form:hidden path="flatType" value="${office.flatType}"/>
		<!-- 上级机构的ID -->
		<input type="hidden" name="parent.id" value="${office.parent.id }" />
		<sys:message content="${message}" />
		<div class="control-group">
			<label class="control-label">归属城市：</label>
			<div class="controls">
				<sys:treeselect id="area" name="area.id" value="${office.area.id}"
					labelName="area.name" labelValue="${office.area.name}" title="区域"
					url="/sys/area/treeData" notAllowSelectParent="true" cssClass="span4 required" />
			</div>
		</div>
		<c:if test="${office.flatType == FLAT_TYPE_ENTERPRISE }">
			<div class="control-group">
				<label class="control-label">旅行社全称：</label>
				<div class="controls">
					<form:input path="name" htmlEscape="false" maxlength="100"
						class="span4 required" />
					<span class="help-inline"><font color="red">*</font> </span>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label">旅行社简称：</label>
				<div class="controls">
					<form:input path="abbr" htmlEscape="false" maxlength="20"
						class="span4 required" />
					<span class="help-inline"><font color="red">*</font> </span>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label">旅行商类型：</label>
				<div class="controls">
					<form:select path="parnertype" class="span4">
						<form:options items="${fns:getDictList('company')}"
							itemLabel="label" itemValue="value" htmlEscape="false" />
					</form:select>
					<span class="help-inline"><font color="red">*</font> </span>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label">可否退票：</label>
				<div class="controls">
					<form:select path="isreturn" class="span4 required"
						onchange="isreturnChange(this.options[this.options.selectedIndex].value)">
						<form:options items="${fns:getDictList('yes_no')}"
							itemLabel="label" itemValue="value" htmlEscape="false" />
					</form:select>
					<span class="help-inline"><font color="red">*</font> </span>
				</div>
			</div>
			<div class="control-group" id="cont"
				<c:if test="${office.isreturn==0}">style="display:none"</c:if>>
				<label class="control-label">退票规则：</label>
				<div class="controls">
					<%-- <form:select path="returnid" class="span4	required">
						<form:option value="" label="" />
						<form:options items="${tReturnrule.returnid}" itemLabel="label" itemValue="value" htmlEscape="false"
							class="span4 required" />
					</form:select> --%>
					<select id="returnid" name="returnid" class="span4 required">
					<option value="">--请选择--</option>
					<c:forEach items="${tRuleList}" var="rtl">
						<option value="${rtl.returnid}"
							<c:if test="${ rtl.returnid eq office.returnid}">selected="selected"</c:if>>
							${rtl.rtnrulename}</option>
					</c:forEach>
					</select>
					<span class="help-inline"><font color="red">*</font> </span>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label">结算模式：</label>
				<div class="controls">
					<form:select path="settletype" class="span4	required">
						<form:options items="${fns:getDictList('settle')}"
							itemLabel="label" itemValue="value" htmlEscape="false" />
					</form:select>
					<span class="help-inline"><font color="red">*</font> </span>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label">企业权重：</label>
				<div class="controls">
					<form:input path="prtyorder" htmlEscape="false" 
						class="span4 required digits" />
					<span class="help-inline"><font color="red">*</font> </span>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label">解锁时间(分钟)：</label>
				<div class="controls">
					<form:input path="locktime" htmlEscape="false"
						class="span4 required digits" />
					<span class="help-inline"><font color="red">*</font> </span>
				</div>
			</div>
		</c:if>

		<c:if test="${office.flatType == FLAT_TYPE_BUS }">
		<div class="control-group">
			<label class="control-label">公司LOGO:</label>
			<div class="controls">
				<form:hidden id="companylogo" path="companylogo" htmlEscape="false" maxlength="200" class="input-xlarge"/>
				<sys:ckfinder input="companylogo" type="images" uploadPath="/company" selectMultiple="false" maxWidth="100" maxHeight="100"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">公司合同章:</label>
			<div class="controls">
				<form:hidden id="contract" path="contract" htmlEscape="false" maxlength="200" class="input-xlarge"/>
				<sys:ckfinder input="contract" type="images" uploadPath="/contract" selectMultiple="false" maxWidth="100" maxHeight="100"/>
			</div>
		</div>
			<div class="control-group">
				<label class="control-label">企业全称：</label>
				<div class="controls">
					<form:input path="name" htmlEscape="false" maxlength="100"
						class="span4 required" />
					<span class="help-inline"><font color="red">*</font> </span>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label">是否显示：</label>
				<div class="controls">
					<input type="radio" name="isshow" value="1" ${office.isshow=="1"?'checked':''}>显示
					<input type="radio" name="isshow" value="0" ${office.isshow=="0"?'checked':''}>不显示
				</div>
			</div>
			<div class="control-group">
				<label class="control-label">企业简称：</label>
				<div class="controls">
					<form:input path="abbr" htmlEscape="false" maxlength="20"
						class="span4 required" />
					<span class="help-inline"><font color="red">*</font> </span>
				</div>
			</div>
			<div class="control-group">
			<label class="control-label">特色服务：</label>
			<div class="controls">
				<table>
					<tr>
						<td>商务套装</td>
						<td>车载wifi</td>
						<td>充电</td>
						<td>矿泉水</td>
						<td>纸巾</td>
					</tr>
					<tr>
						<td>
							<form:select path="businesssuit" htmlEscape="false" class="span1 required">
							<form:options items="${fns:getDictList('yes_no')}"	itemLabel="label" itemValue="value" htmlEscape="false" />
							</form:select>
							<span class="fenge">--</span>
							
						</td>
						<td>
							<form:select path="iswifi" htmlEscape="false" class="span1 required">
							<form:options items="${fns:getDictList('yes_no')}"	itemLabel="label" itemValue="value" htmlEscape="false" />
							</form:select>
							<span class="fenge">--</span>
						</td>
						<td>
							<form:select path="powersupply" htmlEscape="false" class="span1 required">
							<form:options items="${fns:getDictList('yes_no')}"	itemLabel="label" itemValue="value" htmlEscape="false" />
							</form:select>
							<span class="fenge">--</span>
						</td>
						<td>
							<form:select path="tablewater" htmlEscape="false" class="span1 required">
							<form:options items="${fns:getDictList('yes_no')}"	itemLabel="label" itemValue="value" htmlEscape="false" />
							</form:select>
							<span class="fenge">--</span>
						</td>
						<td>
							<form:select path="paper" htmlEscape="false" class="span1 required">
							<form:options items="${fns:getDictList('yes_no')}"	itemLabel="label" itemValue="value" htmlEscape="false" />
							</form:select>
						</td>
					</tr>
					<!-- 错误提示区域 -->
					<tr>
						<td id="td_suitrtnprice">
						</td>
						<td id="td_suitonewayprice">
						</td>
						<td id="td_suitfreeprice">
						</td>
						<td id="td_kms">
						</td>
						<td id="td_lasthour">
						</td>
						<td id="td_vehiclenum">
						</td>
					</tr>
				</table>
			</div>
		</div>
			
		</c:if>

		<%-- <c:if test="${office.flatType == FLAT_TYPE_BUS }"> 
		<div class="control-group">
			<label class="control-label">机构编码：</label>
			<div class="controls">
				<form:input path="code" htmlEscape="false" maxlength="50"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">公司编码：</label>
			<div class="controls">
				<form:input path="querycode" htmlEscape="false" maxlength="20" class="span4 "/>
			</div>
		</div>
		</c:if> --%>
		<div class="control-group">
			<label class="control-label">营业执照编码：</label>
			<div class="controls">
				<form:input path="licenseno" htmlEscape="false" maxlength="20"
					class="span4 required" />
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">组织机构代码编号：</label>
			<div class="controls">
				<form:input path="orgcode" htmlEscape="false" maxlength="20"
					class="span4"  />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">税务登记证编号：</label>
			<div class="controls">
				<form:input path="taxregno" htmlEscape="false" maxlength="20"
					class="span4 " />
			</div>
		</div>
		<!-- 客运特有的字段 -->
		<c:if test="${office.flatType == FLAT_TYPE_BUS }">
			<div class="control-group">
				<label class="control-label">道路经营许可证号：</label>
				<div class="controls">
					<form:input path="permitcode" htmlEscape="false" maxlength="60"
						class="span4" />
				</div>
			</div>
		</c:if>
		<div class="control-group">
			<label class="control-label">开户银行：</label>
			<div class="controls">
				<form:input path="bankname" htmlEscape="false" maxlength="50"
					class="span4 required" />
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">银行账号：</label>
			<div class="controls">
				<form:input path="bankaccount" htmlEscape="false" maxlength="30"
					class="span4 required" />
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		
		<!-- 企业的特有字段 -->
		<c:if test="${office.flatType == FLAT_TYPE_ENTERPRISE }">
		<div class="control-group">
			<label class="control-label">旅游经营许可证编号：</label>
			<div class="controls">
				<form:input path="permitcode" htmlEscape="false" maxlength="60"
					class="span4 digits" />
			</div>
		</div>
			<div class="control-group">
				<label class="control-label">资质等级：</label>
				<div class="controls">
					<form:input path="qualitygrade" htmlEscape="false" maxlength="20"
						class="span4 " />
				</div>
			</div>

		</c:if>
		<div class="control-group">
			<label class="control-label">注册经营地址：</label>
			<div class="controls">
				<form:input path="address" htmlEscape="false" maxlength="255"
					class="span4 " />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">实际经营地址：</label>
			<div class="controls">
				<form:input path="realaddr" htmlEscape="false" maxlength="255"
					class="span4 " />
			</div>
		</div>
		<c:if test="${office.flatType == FLAT_TYPE_ENTERPRISE }">
		<div class="control-group">
			<label class="control-label">计调负责人：</label>
			<div class="controls">
				<form:input path="operator" htmlEscape="false" maxlength="30"
					class="span4 required"  />
					<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">计调负责人手机：</label>
			<div class="controls">
				<form:input path="operatortel" htmlEscape="false" maxlength="20"
					class="span4 required mobile" />
					<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">计调负责人1：</label>
			<div class="controls">
				<form:input path="operatecont" htmlEscape="false" maxlength="30"
					class="span4 " />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">计调负责人手机1：</label>
			<div class="controls">
				<form:input path="operatecontel" htmlEscape="false" maxlength="20"
					class="span4 mobile" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">计调负责人2：</label>
			<div class="controls">
				<form:input path="operatecont2" htmlEscape="false" maxlength="30"
					class="span4 " />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">计调负责人手机2：</label>
			<div class="controls">
				<form:input path="operatecontel2" htmlEscape="false" maxlength="20"
					class="span4 mobile" />
			</div>
		</div>
		</c:if>
		<c:if test="${office.flatType == FLAT_TYPE_BUS }">
		<div class="control-group">
			<label class="control-label">调度联系人：</label>
			<div class="controls">
				<form:input path="operator" htmlEscape="false" maxlength="30"
					class="span4 required"  />
					<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">调度联系人手机：</label>
			<div class="controls">
				<form:input path="operatortel" htmlEscape="false" maxlength="20"
					class="span4 required mobile" />
					<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">调度联系人1：</label>
			<div class="controls">
				<form:input path="operatecont" htmlEscape="false" maxlength="30"
					class="span4 " />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">调度联系人手机1：</label>
			<div class="controls">
				<form:input path="operatecontel" htmlEscape="false" maxlength="20"
					class="span4 mobile" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">调度联系人2：</label>
			<div class="controls">
				<form:input path="operatecont2" htmlEscape="false" maxlength="30"
					class="span4 " />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">调度联系人手机2：</label>
			<div class="controls">
				<form:input path="operatecontel2" htmlEscape="false" maxlength="20"
					class="span4 mobile" />
			</div>
		</div>
		</c:if>
		<div class="control-group">
			<label class="control-label">财务负责人：</label>
			<div class="controls">
				<form:input path="fincharger" htmlEscape="false" maxlength="30"
					class="span4 " />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">财务负责人手机：</label>
			<div class="controls">
				<form:input path="finchargertel" htmlEscape="false" maxlength="20"
					class="span4 mobile" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">财务联系人：</label>
			<div class="controls">
				<form:input path="contacts" htmlEscape="false" maxlength="30"
					class="span4 " />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">财务联系人手机：</label>
			<div class="controls">
				<form:input path="contactstel" htmlEscape="false" maxlength="20"
					class="span4 mobile" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">实际负责人：</label>
			<div class="controls">
				<form:input path="charger" htmlEscape="false" maxlength="30"
					class="span4 " />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">实际负责人手机：</label>
			<div class="controls">
				<form:input path="chargertel" htmlEscape="false" maxlength="20"
					class="span4 mobile" />
			</div>
		</div>
		<%-- <div class="control-group">
			<label class="control-label">联系人：</label>
			<div class="controls">
				<form:input path="contacts" htmlEscape="false" maxlength="30"
					class="span4 " />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">联系人手机：</label>
			<div class="controls">
				<form:input path="contactstel" htmlEscape="false" maxlength="20"
					class="span4 mobile" />
			</div>
		</div> --%>
		
		<%-- <div class="control-group">
			<label class="control-label">是否可用:</label>
			<div class="controls">
				<form:select path="useable">
					<form:options items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
				<span class="help-inline">“是”代表此账号允许登陆，“否”则表示此账号不允许登陆</span>
			</div>
		</div> --%>

		<div class="control-group">
			<label class="control-label">邮编：</label>
			<div class="controls">
				<form:input path="zipCode" htmlEscape="false" maxlength="6"
					class="span4 zipCode" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">法定代表人：</label>
			<div class="controls">
				<form:input path="master" htmlEscape="false" maxlength="50"
					class="span4 " />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">法定代表人手机：</label>
			<div class="controls">
				<form:input path="phone" htmlEscape="false" maxlength="30"
					class="span4 mobile" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">企业电话：</label>
			<div class="controls">
				<form:input path="stabletel" htmlEscape="false" maxlength="20"
					class="span4 " />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">企业传真：</label>
			<div class="controls">
				<form:input path="fax" htmlEscape="false" maxlength="200"
					class="span4 " />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">企业邮箱：</label>
			<div class="controls">
				<form:input path="email" htmlEscape="false" maxlength="200"
					class="span4 email" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">备注：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="3"
					maxlength="255" class="span4" />
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="sys:office:edit">
				<input id="btnSubmit" class="btn btn-primary" type="submit"
					value="保 存" />&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回"
				onclick="history.go(-1)" />
		</div>
	</form:form>
</body>
</html>